package hanjia;

import java.util.Stack;

/**
 * Description:
 * Author:    Dane
 * CreateTime:2025/2/6-下午2:40
 * Since  :   1.0
 * Version:   1.0
 */
public class LeetCode20 {

    public boolean isValid(String s) {
        if (s.length() <= 1) {
            return false;
        }
        Stack<Character> stack = new Stack<>();
        for (char c:s.toCharArray()){
            if (c=='('){
                stack.push(')');
            }else if (c=='['){
                stack.push(']');
            } else if (c=='{') {
                stack.push(']');
            }else if (stack.isEmpty()||stack.pop()!=c){
                return false;
            }
        }
        return stack.isEmpty();


    }
}
